package com.raddle.crud.dao.toolgen;

import com.raddle.crud.model.toolgen.CrudDefinition;
import com.raddle.crud.model.toolgen.CrudDefinitionExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

public interface CrudDefinitionMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table CRUD_DEFINITION
     *
     * @mbggenerated
     */
    int countByExample(CrudDefinitionExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table CRUD_DEFINITION
     *
     * @mbggenerated
     */
    int deleteByExample(CrudDefinitionExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table CRUD_DEFINITION
     *
     * @mbggenerated
     */
    @Delete({
        "delete from CRUD_DEFINITION",
        "where ID = #{id,jdbcType=DECIMAL}"
    })
    int deleteByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table CRUD_DEFINITION
     *
     * @mbggenerated
     */
    @Insert({
        "insert into CRUD_DEFINITION (ID, NAME, ",
        "DEF_TYPE, TABLE_NAME, ",
        "CRUD_DS_ID, PRE_SQL, ",
        "READ_SQL, KEY_SELECT_SQL, ",
        "UPDATE_SQL, ADD_HREF, ",
        "IS_PAGING, AUTO_MATCH_BTN, ",
        "CREATE_TM_COL, UPDATE_TM_COL, ",
        "DELETED, CREATED_AT, ",
        "UPDATED_AT, COMPOSITE_TEMPLATE)",
        "values (#{id,jdbcType=DECIMAL}, #{name,jdbcType=VARCHAR}, ",
        "#{defType,jdbcType=VARCHAR}, #{tableName,jdbcType=VARCHAR}, ",
        "#{crudDsId,jdbcType=DECIMAL}, #{preSql,jdbcType=VARCHAR}, ",
        "#{readSql,jdbcType=VARCHAR}, #{keySelectSql,jdbcType=VARCHAR}, ",
        "#{updateSql,jdbcType=VARCHAR}, #{addHref,jdbcType=VARCHAR}, ",
        "#{isPaging,jdbcType=DECIMAL}, #{autoMatchBtn,jdbcType=DECIMAL}, ",
        "#{createTmCol,jdbcType=VARCHAR}, #{updateTmCol,jdbcType=VARCHAR}, ",
        "#{deleted,jdbcType=DECIMAL}, #{createdAt,jdbcType=TIMESTAMP}, ",
        "#{updatedAt,jdbcType=TIMESTAMP}, #{compositeTemplate,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT SEQ_CRUD_DEFINITION.NEXTVAL FROM DUAL", keyProperty="id", before=true, resultType=Long.class)
    int insert(CrudDefinition record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table CRUD_DEFINITION
     *
     * @mbggenerated
     */
    int insertSelective(CrudDefinition record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table CRUD_DEFINITION
     *
     * @mbggenerated
     */
    List<CrudDefinition> selectByExample(CrudDefinitionExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table CRUD_DEFINITION
     *
     * @mbggenerated
     */
    @Select({
        "select",
        "ID, NAME, DEF_TYPE, TABLE_NAME, CRUD_DS_ID, PRE_SQL, READ_SQL, KEY_SELECT_SQL, ",
        "UPDATE_SQL, ADD_HREF, IS_PAGING, AUTO_MATCH_BTN, CREATE_TM_COL, UPDATE_TM_COL, ",
        "DELETED, CREATED_AT, UPDATED_AT, COMPOSITE_TEMPLATE",
        "from CRUD_DEFINITION",
        "where ID = #{id,jdbcType=DECIMAL}"
    })
    @ResultMap("BaseResultMap")
    CrudDefinition selectByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table CRUD_DEFINITION
     *
     * @mbggenerated
     */
    int updateByExampleSelective(@Param("record") CrudDefinition record, @Param("example") CrudDefinitionExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table CRUD_DEFINITION
     *
     * @mbggenerated
     */
    int updateByExample(@Param("record") CrudDefinition record, @Param("example") CrudDefinitionExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table CRUD_DEFINITION
     *
     * @mbggenerated
     */
    int updateByPrimaryKeySelective(CrudDefinition record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table CRUD_DEFINITION
     *
     * @mbggenerated
     */
    @Update({
        "update CRUD_DEFINITION",
        "set NAME = #{name,jdbcType=VARCHAR},",
          "DEF_TYPE = #{defType,jdbcType=VARCHAR},",
          "TABLE_NAME = #{tableName,jdbcType=VARCHAR},",
          "CRUD_DS_ID = #{crudDsId,jdbcType=DECIMAL},",
          "PRE_SQL = #{preSql,jdbcType=VARCHAR},",
          "READ_SQL = #{readSql,jdbcType=VARCHAR},",
          "KEY_SELECT_SQL = #{keySelectSql,jdbcType=VARCHAR},",
          "UPDATE_SQL = #{updateSql,jdbcType=VARCHAR},",
          "ADD_HREF = #{addHref,jdbcType=VARCHAR},",
          "IS_PAGING = #{isPaging,jdbcType=DECIMAL},",
          "AUTO_MATCH_BTN = #{autoMatchBtn,jdbcType=DECIMAL},",
          "CREATE_TM_COL = #{createTmCol,jdbcType=VARCHAR},",
          "UPDATE_TM_COL = #{updateTmCol,jdbcType=VARCHAR},",
          "DELETED = #{deleted,jdbcType=DECIMAL},",
          "CREATED_AT = #{createdAt,jdbcType=TIMESTAMP},",
          "UPDATED_AT = #{updatedAt,jdbcType=TIMESTAMP},",
          "COMPOSITE_TEMPLATE = #{compositeTemplate,jdbcType=VARCHAR}",
        "where ID = #{id,jdbcType=DECIMAL}"
    })
    int updateByPrimaryKey(CrudDefinition record);
}